package com.shanyutiwen.springbootblogtest.controller;

import com.shanyutiwen.springbootblogtest.model.User;
import com.shanyutiwen.springbootblogtest.service.UserService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.io.IOException;
import java.util.List;

@RestController
public class IndexController {
//    @Resource
//    UserService userService;

//    @GetMapping("/index")
//    public String index() {
//        return "hello index page!";
//    }
//
//    @GetMapping("userList")
//    public List<User> getAllUsers() throws IOException {
//        return userService.getAll();
//    }
//
//    @GetMapping("userList/{id}")
//    public User getUserById(@PathVariable("id") Long id) throws IOException {
//        return userService.findById(id);
//    }
//
//    @GetMapping("userList/condition")
//    public List<User> getConditionsUser() throws IOException {
//
//        return userService.getConditionsUser();
//    }
//
//    @GetMapping("userList/findUserByIds/{ids}")
//    public List<User> findUserByIds(@PathVariable("ids") String ids) throws IOException {
//        int[] idsList = stringToIntArr(ids);
//
//        return userService.findUserByIds(idsList);
//    }

    public static int[] stringToIntArr(String str) {
        int[] intArr = new int[str.length()];
        char[] ch = str.toCharArray();
        for (int i = 0; i < str.length(); i++) {
            intArr[i] = (int) ch[i] - 48;
        }
        return intArr;
    }
}
